/*
 * header file for some custom solutions in C
 * 
 * 	- flushstdin();					clears the stdin (new line character and everything else)
 * 	- strsuffix(char[], char[]);	checks if the second argument is a suffix ot the first or not		
 * 
 * 
 * 
 * author: László Ádám
 * e-mail: adam.laszlo.91@gmail.com
 * 2014. 1. august
 * version: 0.1
 */

#ifndef stuff_h
#define stuff_h

#include <stdio.h>
#include <string.h>

//  flushstdin  //
void flushstdin() {
	int c;
	while ((c = getchar()) != '\n' && c != EOF);
}

//  strsuffix  //
int strsuffix(char src[], char sfx[]){
	strcat(src, "\0");	// always be prepared for strlen()
	strcat(sfx, "\0");
	int src_len = strlen(src);
	int sfx_len = strlen(sfx);
	int i, k;
	if (src_len < sfx_len) return 0;
	i = src_len - sfx_len;
	k = 0;
	for (;i < src_len; i++) {
		if (src[i] != sfx[k]) return 0;
		k++;
	}
	return 1;
}

#endif
